package de.cau.apo.samples;

import java.io.FileNotFoundException;
import java.io.IOException;

import de.cau.apo.CommunicationInterface;
import de.cau.apo.problems.travellingsalesman.Node;
import de.cau.apo.problems.travellingsalesman.TSPInstance;
import de.cau.apo.problems.travellingsalesman.TSPSolution;

public class TravellingSalesmanSample {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		// create instance parse instance file
		TSPInstance instance = new TSPInstance();
		instance.parseInstance(CommunicationInterface.getInstance());
		// create solution by visiting all nodes after each other
		TSPSolution solution = new TSPSolution(instance);
		for (Node node : instance.getNodes()) {
			solution.tour.add(node);
		}
		// publish solution and do debug information output
		if (CommunicationInterface.publishSolution(solution)) {
			System.err.println("Solution is feasible");
		} else {
			System.err.println("Solution is not feasible");
		}
	}

}
